var t = getApp(), e = t.requirejs("core"), a = t.requirejs("foxui"), j = (t.requirejs("jquery"));

Page({

  data: {
    list:[],
    hdlist:[],//活动List
    page:1,
    loadEnd:false,
    tab:0,
  },


  onLoad: function (options) {
    this.getList();
    this.getActivityList();
  },
  toPay(e){
    
    let id = e.currentTarget.dataset.id;//报名id
    wx.navigateTo({
      url: "/signUp/pay/index?sign_id=" + id
    })
  },

  handleTab(e){
    this.setData({
      tab:e.currentTarget.dataset.tab,
    })
  },

  getList: function () {
    var that = this;
    let params = {
      openid: t.getCache("userinfo_openid"),
      page: this.data.page, 
    }
    e.post("activity/get_sign_up_list", params, function (res) {
      if(res.res &&res.res.length>0){
        that.data.list.push.apply(that.data.list, res.res);
        that.setData({
          list:that.data.list,
        })
      }else{
        that.setData({
          loadEnd:true
        })
      }
      
    });
  },

  getActivityList: function () {
    var that = this;
    e.post("activity/get_activity", {}, function (res) {
      if(res.res &&res.res.length>0){
        that.setData({
          hdlist:res.res,
        })
      }
      
    });
  },


  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if(this.data.showNav == 1){
      if(!this.data.loadEnd){
        let pageNum = this.data.page + 1;
        this.setData({
          page:pageNum
        })
        this.getList();
      }
    }
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})